/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       billboard.h
 * Author:     twoja stara
 * Created on: 2009-09-07
 *
 **********************************************************************************************************************/

#ifndef BILLBOARD_H_
#define BILLBOARD_H_

#include "drawable.h"
#include "texturedmaterial.h"

namespace mGameEngine
{
namespace Graphics
{

/**
 * Billboard.
 * Two dimensional image rotated always towards camera.
 */
class Billboard : public Drawable
{
protected:
    /**
     * Texture.
     */
    const Texture *_texture;

    /**
     * Size.
     */
    Vector2 _size;

    /**
     * Center.
     */
    Vector2 _center;

    /**
     * Orientation.
     */
    float _orientation;

public:
    /**
     * Create billboard.
     */
    Billboard();

    /**
     * Create billboard with specified texture, size, center and orientation.
     * @param texture texture.
     * @param size size.
     * @param center center.
     * @param orientation orientation angle in radians.
     */
    Billboard(const Texture *texture,
              const Vector2 &size = Vector2(1.0f, 1.0f),
              const Vector2 &center = Vector2(0.5f, 0.5f),
              float orientation = 0.0f);

    /**
     * Destroy billboard.
     */
    virtual ~Billboard();

    /**
     * Get billboard texture.
     * @return billboard texture.
     */
    const Texture *getTexture() const
    {
        return _texture;
    }

    /**
     * Set billboard texture.
     * @param texture texture.
     */
    void setTexture(const Texture *texture)
    {
        _texture = texture;
    }

    /**
     * Get billboard size.
     * @return billboard size.
     */
    const Vector2 &getSize() const
    {
        return _size;
    }

    /**
     * Set billboard size.
     * @param size size.
     */
    void setSize(const Vector2 &size)
    {
        _size = size;
    }

    /**
     * Get billboard center.
     * @return billboard center.
     */
    const Vector2 &getCenter() const
    {
        return _center;
    }

    /**
     * Set billboard center.
     * @param center center.
     */
    void setCenter(const Vector2 &center)
    {
        _center = center;
    }

    /**
     * Get billboard orientation angle.
     * @return billboard orientation angle in radians.
     */
    float getOrientation() const
    {
        return _orientation;
    }

    /**
     * Set billboard orientation angle.
     * @param orientation orientation angle in radians.
     */
    void setOrientation(float orientation)
    {
        _orientation = orientation;
    }

    /**
     * Rotate billboard.
     * @param rotation rotation angle in radians.
     */
    void rotate(float rotation)
    {
        _orientation += rotation;
    }

    /**
     * Draw billboard.
     */
    virtual void draw() const;
};

}
}

#endif // BILLBOARD_H_
